home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / CP.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  2.7 KB  |  131 lines

  1. *******************************************************
  2. **      XFD external decruncher for CP Cruncher      **
  3. **        written by Mr. Larmer / Wanted Team        **
  4. **  fixed by Georg Hörmannn in 1998 and SDI in 1999  **
  5. *******************************************************
  6.  
  7.         INCLUDE    "AINCLUDE:IncDirs.i"
  8.         INCLUDE    "libraries/xfdmaster.i"
  9.  
  10.         * head function for tests
  11. *        INCLUDE    "xfdExeHead.a"
  12.  
  13. ; xfdForeman structure MUST be first thing in all external decrunchers
  14.  
  15. ForeMan        moveq    #-1,d0        ;security
  16.         rts
  17.         dc.l    XFDF_ID        ;id
  18.         dc.w    1        ;version
  19.         dc.w    0
  20.         dc.l    0,0        ;private
  21.         dc.l    S_CP        ;first slave
  22.  
  23. **************************************************
  24.  
  25. ; xfdSlave structure: this one doesn't support data scanning
  26.  
  27. S_CP        dc.l    0        ;no more slaves
  28.         dc.w    2        ;version
  29.         dc.w    39        ;master version
  30.         dc.l    N_CP        ;name
  31.         dc.w    XFDPFF_DATA|XFDPFF_RECOGLEN|XFDPFF_USERTARGET
  32.         dc.w    0
  33.         dc.l    RB_CP        ;recog buffer
  34.         dc.l    DB_CP        ;decrunch buffer
  35.         dc.l    0        ;recog segment
  36.         dc.l    0        ;decrunch segment
  37.         dc.w    0,0
  38.         dc.l    12+2
  39.  
  40.         dc.b    "$VER: CP 2.0 (20.02.1999)",0
  41. N_CP        dc.b    "(CP) Data Cruncher",0
  42.         even
  43.  
  44. ;-------------------------------------------------
  45.  
  46. ; Recog buffer function: receives buffer + length in a0/d0
  47.  
  48. RB_CP        MOVEQ    #0,D0
  49.         CMP.W    #"CP",(A0)
  50.         BNE.B    .Exit
  51.         TST.B    4(A0)
  52.         BNE.B    .Exit
  53.         TST.B    8(A0)
  54.         BNE.B    .Exit
  55.         MOVE.L    8(A0),xfdrr_FinalTargetLen(A1)
  56.         MOVE.L    8(A0),xfdrr_MinTargetLen(A1)
  57.         MOVE.L    4(A0),xfdrr_MinSourceLen(A1)
  58.         MOVEQ    #1,D0
  59. .Exit        RTS
  60.  
  61. ;-------------------------------------------------
  62.  
  63. ; Decrunch buffer function: receives bufferinfo in a0
  64. ; This style requires xfdmaster.library V39
  65. DB_CP        MOVEM.L    D2-D7/A2-A6,-(A7)
  66.         MOVEA.L    A0,A4
  67.         MOVE.L    xfdbi_UserTargetBuf(A4),A1
  68.         MOVEA.L    A1,A5
  69.         ADDA.L    xfdbi_TargetBufSaveLen(A4),A5
  70.         MOVE.L    xfdbi_SourceBuffer(A4),A0
  71.  
  72.         LEA    $10(A0),A2
  73.         move.l    8(A0),D1
  74.         move.w    12(A0),D0
  75.         lea    (A0,D0.W),A3
  76.         move.w    14(A0),D0
  77.         lea    (A0,D0.W),A0
  78.         move.b    #$80,D3
  79. .decr1        move.b    (A2),D0
  80.         and.b    D3,D0
  81.         bne.s    .decr4
  82.         CMPA.L    A5,A1        * overrun check
  83.         BEQ.B    .Err
  84.         move.b    (A0)+,(A1)+
  85.         subq.l    #1,D1
  86. .decr2        ror.b    #1,D3
  87.         bpl.s    .decr3
  88.         addq.l    #1,A2
  89. .decr3        tst.l    D1
  90.         bne.s    .decr1
  91.         MOVEQ    #1,D0
  92. .End        MOVEM.L    (A7)+,D2-D7/A2-A6
  93.         RTS
  94.  
  95. .Err        MOVE.W    #XFDERR_CORRUPTEDDATA,xfdbi_Error(A4)
  96.         MOVEQ    #0,D0
  97.         BRA.B    .End
  98.  
  99. .decr4        move.b    (A3)+,D6
  100.         lsl.w    #8,D6
  101.         move.b    (A3)+,D6
  102.         move.w    D6,D7
  103.         andi.w    #$F000,D7
  104.         eor.w    D7,D6
  105.         bne.s    .decr5
  106.         move.w    #$1000,D6
  107. .decr5        movea.l    A1,A6
  108.         suba.w    D6,A6
  109.         rol.w    #4,D7
  110.         cmpi.w    #15,D7
  111.         bcs.s    .decr7
  112.         andi.w    #$FF,D6
  113. .decr6        move.b    (A3)+,D6
  114.         add.w    D6,D7
  115.         cmpi.b    #$FF,D6
  116.         beq.s    .decr6
  117. .decr7        andi.l    #$FFFF,D7
  118.         sub.l    D7,D1
  119.  
  120.         MOVE.L    A1,D6        * overrun check
  121.         ADD.L    D7,D6
  122.         CMPA.L    D6,A5
  123.         BLO.B    .Err
  124.  
  125.         subq.w    #1,D7
  126. .decr8        move.b    (A6)+,(A1)+
  127.         dbra    D7,.decr8
  128.         bra.b    .decr2
  129.  
  130.         END
  131.